package com.lonely.web.controller.goods;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lonely.common.core.domain.api.R;
import com.lonely.goods.domain.dto.material.MaterialItemPageQueryDTO;
import com.lonely.goods.domain.vo.material.items.MaterialItemVO;
import com.lonely.goods.domain.vo.material.items.MaterialItemPageVO;
import com.lonely.goods.service.IMaterialItemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author : 黄志标
 * @date: 2025/7/11 14:15
 * @description:
 */
@RestController
@RequestMapping("/goodsManager/material/item")
@Api(tags = "商品管理/物料明细")
public class MaterialItemController {

    @Autowired
    private IMaterialItemService materialItemService;

    /**
     * 物料明细分页查询
     *
     * @param queryDto
     * @return
     */
    @PostMapping("/queryMaterialItemPage")
    @ApiOperation(value = "物料明细分页查询")
    public R<Page<MaterialItemPageVO>> queryMaterialItemPage(@RequestBody @Validated MaterialItemPageQueryDTO queryDto) {
        return R.data(materialItemService.queryMaterialItemPage(queryDto));
    }



    /**
     * 获取指定物料明细id对应的物料明细信息
     *
     * @param materialItemId
     * @return
     */
    @GetMapping("/getMaterialItemDetail/{materialItemId}")
    @ApiOperation(value = "获取指定物料明细id对应的物料明细信息")
    public R<MaterialItemVO> getMaterialItemDetail(@PathVariable("materialItemId") Long materialItemId) {
        return R.data(materialItemService.getMaterialItemDetail(materialItemId));
    }
}
